import { defineStore } from 'pinia'
import { Locale } from 'vant';
import enUS from 'vant/es/locale/lang/en-US';
import zhCN from 'vant/es/locale/lang/zh-CN';
import jaJP from 'vant/es/locale/lang/ja-JP';

export const useCommonStore = defineStore('common', {

    state: () => {
      return {
        activeMenuNames: [] as string[],
        cacheScroll: {},
        language: Language.zhCN,
        $i18n: {} as any
      }
    },
    actions: {
      setLanguage(inLanguage:Language , locale: any) {
        this.language = inLanguage;
        switch(inLanguage){
          case Language.zhCN:
            Locale.use('zh-CN', zhCN);
            console.log()
            locale.value = 'zhCN';
            break;
          case Language.jaJP:
            Locale.use('ja-JP', jaJP);
            locale.value = 'jaJP';
            break;
          case Language.enUS:
            Locale.use('en-US', enUS);
            locale.value = 'enUS';
            break;
        }
      }
    }
  }
)


export enum Language{
  zhCN = "中文",
  jaJP = "日本語",
  enUS = "English"
}